import request from '@/router/axios';

//获取承运商列表
export const getList = (current, size, params) => {
  return request({
    url: '/api/blade-tms/userInfo/CarrierManagement/list',
    method: 'get',
    params: {
      ...params,
      current,
      size,
    }
  })
}
//承运商编辑
export const update = (data) => {
  return request({
    url: '/api/blade-tms/userInfo/CarrierManagement/update',
    method: 'post',
    data: {
      ...data,
    }
  })
}
//司机列表
export const getDriverList = (current, size, params) => {
  return request({
    url: '/api/blade-tms/userInfo/CarrierManagement/driverList',
    method: 'get',
    params: {
      ...params,
      current,
      size,
    }
  })
}
//重置密码
export const resetPassword = (data) => {
  return request({
    url: '/api/blade-tms/userInfo/CarrierManagement/resetPassword',
    method: 'post',
    data: {
      ...data,
    }
  })
}
//车辆列表
export const getCarList = (current, size, data) => {
  return request({
    url: '/api/blade-tms/userInfo/CarrierManagement/carList',
    method: 'post',
    data: {
      ...data,
      current,
      size,
    }
  })
}
//承运商绑定解绑（司机/车辆/押运员）
export const bindOrUnBind = (data) => {
  return request({
    url: '/api/blade-tms/userInfo/Bind/bindOrUnBind',
    method: 'post',
    data: {
      ...data,
    }
  })
}
//获取承运商资质审查列表
export const getQualificationReviewList = (current, size, params) => {
  return request({
    url: '/api/blade-tms/userInfo/CarrierManagement/qualificationReview',
    method: 'get',
    params: {
      ...params,
      current,
      size,
    }
  })
}
//承运商审核
export const carrierCheck = (data) => {
  return request({
    url: '/api/blade-tms/userInfo/CarrierManagement/check',
    method: 'post',
    headers: {
      'Content-Type': 'application/json'
    },
    transformRequest(data) {
      return data
    },
    data: JSON.stringify(data)
  })
}
//承运商个人信息查询
export const getPersonalInformation = () => {
  return request({
    url: '/api/blade-tms/userInfo/CarrierManagement/personalInformation',
    method: 'get',
  })
}
//承运商个人信息修改
export const updatePersonalInformation = (data) => {
  return request({
    url: '/api/blade-tms/userInfo/CarrierManagement/update',
    method: 'post',
    data: {
      ...data,
    }
  })
}
//根据手机号给当前用户绑定车辆或司机或押运员
export const phoneBind = (data) => {
  return request({
    url: '/api/blade-tms/userInfo/Bind/phoneBind',
    method: 'post',
    data: {
      ...data,
    }
  })
}
//司押运员列表
export const getEscortList = (current, size, params) => {
  return request({
    url: '/api/blade-tms/userInfo/CarrierManagement/escortList',
    method: 'get',
    params: {
      ...params,
      current,
      size,
    }
  })
}
//司押运员列表
export const getTankList = (current, size, params) => {
  return request({
    url: '/api/blade-tms/userInfo/CarrierManagement/tankList',
    method: 'get',
    params: {
      ...params,
      current,
      size,
    }
  })
}
//承运商组别
export const carrierGroup = async () => {
  const res = await request({
    url: '/api/blade-tms/systemConfig/carrierGroup',
    method: 'get'
  });
  if (res.data.code === 200 && res.data.success) {
    return JSON.parse(res.data.data)
  }
  return [];
}
//分配组别
export const assignGroup = (data) => {
  return request({
    url: '/api/blade-tms/userInfo/CarrierManagement/assignGroup',
    method: 'post',
    data: {
      ...data,
    }
  })
}
